package com.bestcem.xm.member.entity.mongo;

import com.bestcem.xm.common.core.uitls.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * @author ming.xue <ming.xue@idiaoyan.com>
 * @desc 实体基类
 * @date 2021-05-19
 */
@Getter
@Setter
public abstract class BaseEntity {
    /**
     * 实体标识
     */
    protected String id;

    /**
     * 创建时间
     */
    @JsonProperty("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+0")
    protected Date createTime;

    /**
     * 修改时间
     */
    @JsonProperty("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    protected Date updateTime = DateUtil.getCommonDate();

    /**
     * 填充默认值
     */
    public void fillDefaultValue() {
        this.createTime = DateUtil.getCommonDate();
    }
}
